package com.blockmeta.bbs.immodule.corebean;

import com.blockmeta.bbs.businesslibrary.pojo.MessageParam;
import com.blockmeta.bbs.immodule.adapter.ImSessionListAdapter;
import com.blockmeta.bbs.immodule.dao.ChatMessage;
import com.blockmeta.bbs.immodule.dao.IMUserEntity;

import java.util.List;

/**
 * 领域服务，提供抽象服务以使控制层无需直接接触数据访问层，同时使控制层的业务可以复用，控制层无需了解下层的实现封装。
 * 数据层提供的抽象应当不包含业务逻辑，避免同层调用。
 */
public interface IChatMessageDomainService {
    ChatMessage makeChatMessage(MessageParam messageParam);

    void updateChatMessageReaded(Long id, boolean readorUnread);

    void deleteListChatMessage(long uidInt, ChatMessage cm);

    void updateChatMessageChecked(long uidInt, long toUserId, int msgTypeUcg);

    String getShowContent(IMUserEntity IMUserEntity, ChatMessage message);

    void sendUncheckCountEvent();

    int getUnCheckedMsgCount(long uidInt);

    int getTalkListMessageSize(long uid);

    /**
     * 根据新消息所在的位置改变adapter的项更新
     * @param mAdapter
     * @param newMsg
     */
    void notifyMsgListViewChange(ImSessionListAdapter mAdapter, ChatMessage newMsg);

    void updateChatMessageStatus(String uuid, int statusFailTimeout);

    void updateMessageStatusToFail(long uidInt);

    boolean isMessageStick(ChatMessage item);

    void getKlineContentBean(String name, String exchange, String logo, GetResultCallBack getResultCallBack);

    void updateChatMessageContent(String uuid, String downLoadFileName);

    ChatMessage replaceChatMessageByUuid(String uuid, String uuid1);

    long getMaxMessageIdByUserId(long userId);

    /**
     * 添加消息，如果消息uuid已经存在，更新消息后返回false,否则为true
     * @param message
     * @param uidInt
     * @return
     */
    boolean addChatMessage(ChatMessage message, long uidInt);

    void updateChatMessage(ChatMessage message);

    void updateCircleStick(long mCircleId, boolean b);

    boolean getCircleStick(long mCircleId, int msgTypeUcg);

    void deleteChatMessageById(Long id);

    List<ChatMessage> getChatMessageList(long uidInt, long toUserId, int chatType, int fetchSize, long ltMessageId, long gtMessageId);

    long getUnReadCount(long uidInt, long toUserId, int chatType);

    void updateChatMessageStick(Long id, boolean b);

    List<ChatMessage> getTalkListMessage(long uid);

    int getUncheckedMessageCountExceptNoDisturb(long uidInt, List<Long> noDisturbGroupIds);

    void deleteCircleChatMessage(long uidInt, long mCircleId);

    List<ChatMessage> getLocChatMessageList(long uidInt, long toUserId, int chatType, int pageSize, long locMessageId);

    ChatMessage getChatMessageListByUUid(String uuid);

    void notifyMsgListViewUserReaded(ImSessionListAdapter mAdapter, long toUserId, int type);

    List<ChatMessage> getGroupTalkListMessage(int uidInt);

    List<ChatMessage> getPersonalTalkListMessage(int uidInt);

    interface GetResultCallBack {
        void fail(String msg);

        void success(String content);
    }

    /**
     * 查询我的消息分页
     * @param word
     * @param pageSize
     * @param page
     * @param orderField
     * @param orderType
     * @return
     */
    List<ChatMessage> searchChatMessagePaged(String word, int pageSize, int page, String orderField, String orderType);
}
